<!DOCTYPE html>
<html>
<head>
	<title>待办任务查询</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <script type="text/javascript">
        var path = window.document.location.href;
        var pathName = window.document.location.pathname;
        var hostPath = path.substring(0, path.indexOf(pathName));
        var projectName = pathName.substring(0, pathName.substr(1).indexOf("/") + 1);
        document.write('<scr' + 'ipt src="' + projectName + '/js/html/header.js"></scr'+'ipt>');
    </script>
</head>
<body>
	<table id="dg" style="width: auto; height: auto" fitColumns="true">
		<thead>
			<tr>
				<th field="id" align="right" width="100" 
					data-options="
					sortable:true,
					remoteSort:false
					">任务ID</th>
				<th field="procDefName" align="right" width="100"
					data-options="
					sortable:true,
					remoteSort:false
					">流程名称</th>
				<th field="businessKey" align="right" width="100"
					data-options="
					sortable:true,
					remoteSort:false
					">业务主键</th>
				<th field="procInstId" align="right" width="100" 
					data-options="
					sortable:true,
					remoteSort:false
					">流程实例ID</th>
				<th field="procDefId" align="right" width="100" 
					data-options="
					sortable:true,
					remoteSort:false
					">流程模版发布序号</th>
				<th field="name" align="right" width="100" 
					data-options="
					sortable:true,
					remoteSort:false
					">任务名称</th>
				<th field="taskDefKey" align="right" width="100"  data-options="hidden:true"
					data-options="
					sortable:true,
					remoteSort:false
					">任务节点key</th>
				<th field="owner" align="right" width="100"  data-options="hidden:true"
					data-options="
					sortable:true,
					remoteSort:false
					">OWNER_</th>
				<th field="assignee" align="right" width="100" 
					data-options="
					sortable:true,
					remoteSort:false
					">处理人</th>
				<th field="createTime" align="right" width="100" 
					data-options="
					sortable:true,
					remoteSort:false
					">任务生成时间</th>
				<th field="act" align="center" data-options="
						sortable:true,
						remoteSort:false,
						formatter:actFormatter
						">操作</th>
			</tr>
		</thead>
	</table>
	<div id="dg-buttons" style="height: auto">
		<div style="margin-bottom:5px">
			<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:true" 	onclick="comments()">审批轨迹</a>
		</div>
		<div>
			<span>&nbsp;&nbsp;&nbsp;&nbsp;选择:</span>
			<input type="text" id="searchKey" name="searchKey" class="easyui-combobox" />
			<span>等于:</span>
			<input type="text" id="searchValue" name="searchValue" class="easyui-validatebox" />
			<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" onclick="dgop.find()">查询</a>
		</div>
	</div>
	
	<!--隐藏的文本框-->
	<div id="win" class="easyui-window" title="工作流任务" style="width: 800px; height: 450px" closed="true" data-options="iconCls:'icon-save',modal:true">
		<div id="centers" data-options="region:'center',title:'center title'" style="padding: 5px; background: #eee; height: 90%"></div>
	</div>
	
	<img id="ImagePic"  style="width: auto; height: auto" />


	<script>
		var initd = {
			queryDataURL : "/workflow/task/list/currusertodo",
			displayDataURL:"/workflow/process/display",
			pageSize : 10,
			dg : $('#dg')
		};
		
		function comments() {
			var selectedRows = $("#dg").datagrid("getSelections");
			if (selectedRows.length != 1) {
				$.messager.progress("close");
				$.messager.alert("系统提示", "请选择一条要编辑的数据！");
				return false;
			}
			var row = selectedRows[0];
			var designerUrl = projectName+"/html/workflowManage/taskinfo/approvalComments.html?procInstId=" + row.procInstId + "&taskId=" + row.id;
			var feature = 'top=0, left=0,toolbar=no,menubar=yes, scrollbars=yes, resizable=yes,location=no,status=no,channelmode = yes';
            var newwindows = window.open(designerUrl, "", feature);
            newwindows.moveTo(0, 0); //将新页面打开位置定位在屏幕左上角
            newwindows.resizeTo(screen.width, screen.height); //设置新页面的大小
            if (newwindows != null) {
                newwindows.focus();//新页面获得焦点
            }
		}

		function actFormatter(val, row, index) {
			return '<a onclick="doWorkFlow(\''
					+ row['id']
					+ '\',\''
					+ row['procInstId']
					+ '\',\''
					+ row['procDefId']
					+ '\',\''
					+ row['taskDefKey']
					+ '\',\''
					+ row['businessKey']
					+ '\')"><IMG border="0" src="'+projectName+'/images/common/dotask.png" width="19" height="19"></a>';
		}

		function doWorkFlow(taskId, procInstId, processkey,
				taskDefKey,businessKey) {
			var handleview = handleView(processkey,taskDefKey,businessKey);
			$("#win").window("open");
			var hrefs = '<iframe id="son" src="'
					+ projectName
					+ handleview
					+ '?procInstId='
					+ procInstId
					+ '&taskId='
					+ taskId
					+ '&processKey='
					+ processkey
					+ '&taskDefKey='
					+ taskDefKey
					+ '&businessKey='
					+ businessKey
					+ '" allowTransparency="true" style="border:0;width:99%;height:99%;padding-left:2px;" frameBorder="0"></iframe>';
			$("#centers").html(hrefs);
		}
		
		
		function handleView(processkey,taskDefKey,businessKey) {
			var handleView = "";
			$.ajax({
				type : "POST",
				async:false,
				url : projectName + "/workflow/config/handleview",
				data : JSON.stringify({
					'processDefKey' : processkey,
					'taskDefKey' : taskDefKey,
					'businessKey' : businessKey
				}),
				dataType : "json",
				contentType : "application/json;charset=utf-8",
				success: function (data) {
                    if (!data.success) {
                        alert(data.message);
                        return;
                    }
                    handleView = data.entity;
                },
                error: function (err, status) {
                    initd.dg.datagrid('loaded');
                    errorMsgAlert(err);
                }
			});
			
			return handleView;
		}
		
	</script>
</body>
</html>

